<script setup lang="ts">
	import { ref, onMounted } from "vue";
	import { formRules } from "./utils/rule";
	import { FormProps } from "./utils/types";
	import ReCol from "@/components/ReCol";
	const props = withDefaults(defineProps<FormProps>(), {
		formInline: () => ({
			title: "新增",
			isTicketOption: null,
			behaveCodeOption: null
		})
	});


	const ruleFormRef = ref();
	const newFormInline = ref(props.formInline);

	function getRef() {
		return ruleFormRef.value;
	}
	defineExpose({ getRef });

</script>

<template>
	<el-form ref="ruleFormRef" :model="newFormInline" :rules="formRules" label-width="auto">
		<el-row :gutter="30">
			<re-col :value="24" :xs="24" :sm="24">
				<el-form-item label="报警行为名称" prop="name">
					<el-input v-model="newFormInline.name" clearable placeholder="请输入报警行为名称" :maxlength="30"/>
				</el-form-item>
			</re-col>
			<re-col :value="24" :xs="24" :sm="24">
				<el-form-item label="报警行为" prop="behaveCode">
					<el-select v-model="newFormInline.behaveCode" multiple placeholder="请选择报警行为">
						<el-option v-for="item in newFormInline.behaveCodeOption" :key="item.code" :label="item.code" :value="item.code" />
					</el-select>
				</el-form-item>
			</re-col>
			<re-col :value="24" :xs="24" :sm="24">
				<el-form-item label="生成工单" prop="isTicket">
					<el-select v-model="newFormInline.isTicket" placeholder="请选择是否生成工单">
						<el-option v-for="item in newFormInline.isTicketOption" :key="item.id" :label="item.name" :value="item.id" />
					</el-select>
				</el-form-item>
			</re-col>
			<re-col :value="24" :xs="24" :sm="24">
				<el-form-item label="时间间隔(分钟)" prop="interval">
					<el-input-number v-model="newFormInline.interval" :min="1" :max="99999" :precision="0" />
				</el-form-item>
			</re-col>
			<re-col :value="24" :xs="24" :sm="24">
				<el-form-item label="备注">
					<el-input v-model="newFormInline.remarks" :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
						placeholder="请输入备注" :maxlength="100" show-word-limit />
				</el-form-item>
			</re-col>

		</el-row>
	</el-form>
</template>
<style scoped></style>